﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using V5_Common.FileManager;
using V5_Common;

namespace V5_EShop.Admin.Picture
{
    public partial class Picture_Manage_Dialog_3 : System.Web.UI.Page
    {
        string rootPath = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            rootPath = Server.MapPath("~/");
            string path = Input.SetString(Request["uploadpath"]);
            if (path == "")
            {
            }
            else
            {

                //if (!this.IsPostBack)
                //{

                //}
                //this.Bind_DirsList();

            }
            this.Bind_FilesList();
        }

        private void Bind_DirsList()
        {

        }

        private void Bind_FilesList()
        {
            string path = Server.MapPath("~/");
            FileSystemManager.SetRootPath(path);
            List<FileSystemItem> list = FileSystemManager.GetItems();
            this.gvFilesList.DataSource = list;
            this.gvFilesList.DataBind();
            this.Label1.Text += path;
        }

        public string Bind_Name(object fullname, object name, object isfolder)
        {
            string s1 = name.ToString();
            string s2 = isfolder.ToString().ToLower();
            string s3 = fullname.ToString();
            string s4 = s3.ToLower().Substring(rootPath.Length);
            string tempstr = "";
            if (s2 == "true")
            {
                tempstr = "<img src='/sysImages/FileIcon/folder.gif'/>" + s1;
            }
            else
            {
                tempstr = "<div src=\"" + s4 + "\" ondblclick=\"parent.InitPicture(this)\"><img src='/sysImages/FileIcon/gif.gif' onclick='parent.InitPicture(this);'/>" + s1 + "</div>";
            }
            return tempstr;
        }
    }
}
